{
"cells": [
{
"cell_type": "markdown",
"id": "fa37ce86",
"metadata": {},
"source": [
" \n",
"\n",
"# Quantum Operations and Simulations in Qiskit\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"id": "bbe310ff",
"metadata": {},
"source": [
"\n",
"## Contents\n",
"\n",
"1. [Introduction](#introduction)\n",
"\n",
" 1.1 [Overview of Qiskit](#qiskit_overview)\n",
" \n",
" 1.2 [The quantum bit](#quantum_bit)\n",
" \n",
" \n",
"2. [Single-qubit states](#single_states)\n",
"\n",
" 2.1 [Single-qubit operations](#single_operations)\n",
" \n",
"\n",
"3. [Multi-qubit states](#multi_qubits)\n",
"\n",
" 3.1 [Multi-qubit operations](#multi_op)\n",
" \n",
" \n",
"4. [Summary](#summary)"
]
},
{
"cell_type": "markdown",
"id": "8cb64fe2",
"metadata": {},
"source": [
" \n",
"\n",
"# 1. Introduction\n",
"\n",
"\n",
"This set of classes draws ideas from an abundance of online learning materials for Qiskit, particularly the [Qiskit online tutorials](https://github.com/Qiskit/qiskit-iqx-tutorials) and [textbook](https://qiskit.org/textbook/preface.html). Another source was Miguel Ramalho's [Teach me quantum](https://github.com/msramalho/Teach-Me-Quantum), which was [recognized](https://dei.fe.up.pt/en/blog/2019/03/15/we-have-winners-of-the-ibm-q-teach-me-quantum-challenge/) by IBM.\n",
"\n",
"Images that are not our own were adapted from the IBM Q experience documentation and public Qiskit materials."
]
},
{
"cell_type": "markdown",
"id": "53c8d8ab",
"metadata": {},
"source": [
" \n",
"\n",
"## 1.1. QISKit - an overview\n",
"\n",
" Trusted Notebook\" width=\"400 px\" align=\"center\">\n",
"\n",
"Qiskit is an open-source framework for working with quantum computers at the level of algorithms, quantum circuits, or even pulses. It can be installed and executed locally, but to execute your code in actual, public access quantum processors, you need to create a [IBM Quantum experience](https://quantum-computing.ibm.com) account.\n",
"\n",
"\n",
"Its main goals are:\n",
"\n",
" - to build a software stack for the development of quantum software and applications;\n",
" - to make it easier for students to understand and learn about quantum computation;\n",
" - to facilitate research on the most important open issues facing quantum computation today.\n",
"\n",
"Qiskit supports the *Python* language, which is itself compatible with multiple programming paradigms.\n",
"\n",
"\n",
"The main pillar of this toolkit (which the majority of these classes will feature) is **Qiskit Terra**, and it allows us to:\n",
"\n",
"- compose quantum programs at the level of circuits and pulses;\n",
"- optimize them for the constraints of a particular device;\n",
"- interact with the execution backends.\n",
"\n",
" \n",
"
┌───┐\n", "qubit_0: ┤ X ├\n", " ├───┤\n", "qubit_1: ┤ Y ├\n", " ├───┤\n", "qubit_2: ┤ Z ├\n", " └───┘" ], "text/plain": [ " ┌───┐\n", "qubit_0: ┤ X ├\n", " ├───┤\n", "qubit_1: ┤ Y ├\n", " ├───┤\n", "qubit_2: ┤ Z ├\n", " └───┘" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create registers\n", "qr = QuantumRegister(3, 'qubit')\n", "\n", "# Quantum circuit\n", "qc_pauli = QuantumCircuit(qr)\n", "\n", "# Perform X gate on qubit 0\n", "qc_pauli.x(qr[0])\n", "\n", "# Perform Y gate on qubit 1\n", "qc_pauli.y(qr[1])\n", "\n", "# Perform Z gate on qubit 2\n", "qc_pauli.z(qr[2])\n", "\n", "# Draw circuit\n", "qc_pauli.draw()" ] }, { "cell_type": "markdown", "id": "ac11384b", "metadata": {}, "source": [ "### Hadamard gate\n", "\n", "The Hadamard gate may be used to create superposition. It maps the basis state $| 0 \\rangle$ to $| + \\rangle =\\frac{| 0 \\rangle + | 1 \\rangle }{\\sqrt{2}}$, and $| 1 \\rangle $ to $ | - \\rangle =\\frac{ |0 \\rangle - |1 \\rangle }{\\sqrt{2}}$. On the Bloch sphere, $| + \\rangle$ and $| - \\rangle $ are represented by points on the X axis. \n", "\n", "When measured, these states have equal probability of becoming $| 1\\rangle $ or $| 0 \\rangle $, since the square modulus of the probability amplitude for each of the basis states has equal value.\n", "\n", "
┌───┐\n", "q4: ┤ H ├\n", " └───┘" ], "text/plain": [ " ┌───┐\n", "q4: ┤ H ├\n", " └───┘" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "qr = QuantumRegister(1) \n", "\n", "# Quantum circuit\n", "q_hadamard = QuantumCircuit(qr)\n", "\n", "# Perform the operation\n", "q_hadamard.h(qr)\n", "\n", "# Draw the circuit\n", "q_hadamard.draw()" ] }, { "cell_type": "markdown", "id": "a570f7f3", "metadata": {}, "source": [ "